package com.cloudsigns.factorymanager2.project.presenter;

import com.cloudsigns.factorymanager2.project.iview.ISurveyFeedbackAddView;
import com.cloudsigns.factorymanager2.project.model.ISurveyFeedbackAddModel;
import com.cloudsigns.factorymanager2.project.model.SurveyFeedbackAddModel;

/**
 * Created by tony on 2018/8/18.
 */

public class SurveyFeedbackAddPresenter {
    private ISurveyFeedbackAddView view;
    private ISurveyFeedbackAddModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public SurveyFeedbackAddPresenter(ISurveyFeedbackAddView view) {
        this.view = view;
        this.model = new SurveyFeedbackAddModel();
    }

    public void surveyFeedbackAdd() {

        model.surveyFeedbackAdd(view.getOrderId(),  view.getBaseInfoList(), view.getPrepareList(), view.getSizeList(), new SurveyFeedbackAddModel.OnSurveyFeedbackAdListener() {

            @Override
            public void surveyFeedbackAdSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.surveyFeedbackAddSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void surveyFeedbackAdFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.surveyFeedbackAddFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
